package com.github.thinwonton.cas.showcase.webapp.cms.service.impl;

import com.github.thinwonton.cas.showcase.webapp.cms.service.UserService;

import java.util.HashSet;
import java.util.Set;

/**
 * 模拟数据
 */
public class MockUserServiceImpl implements UserService {
    @Override
    public Set<String> findRoles(String username) {
        HashSet<String> roles = new HashSet<>();

        if ("admin".equals(username)) { //添加admin角色
            roles.add("admin");
        } else if ("test".equals(username)) {
            roles.add("test");
        }
        return roles;
    }

    @Override
    public Set<String> findPermissions(String username) {
        HashSet<String> permissions = new HashSet<>();

        if ("admin".equals(username)) {
            //admin有文章创建和查看的权限
            permissions.add("article:create");
            permissions.add("article:show");
        } else if ("test".equals(username)) {
            //test只有文章查看的权限
            permissions.add("article:show");
        }
        return permissions;
    }
}
